<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>

<!--BOTON cerrado + condicion de actualización-->
<button type="button" class="slideDer-cerrar" onclick="javascritp:LoadUser('<?php echo url_for("dashboard/$parent")?>','<?php echo $idUser ?>','');MenuClose();"></button>
<!--Division del formulario-->
<div class="jwj-callcenter-div"></div>

<!--Formulario con declaración de class y de ID Formulario-->
<form class="formGeneralModel" id="myForm" action="<?php echo url_for('formulario/'.($form->getObject()->isNew() ? 'createServicio' : 'updateServicio').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table class="formGeneralTable" border="0" cellspacing="0" cellpadding="0" width="100%">
   
    <tbody>
      <?php echo $form->renderGlobalErrors() ?>
        <tr class="addEtiquetaTitulo">
            <td colspan="2"><p>Datos Basicos</p></td>
      </tr>
      <tr class="addEtiquetaFila">
        <td><?php echo $form['mascota_id']->renderLabel() ?></td>
        <td>
          <?php echo $form['mascota_id']->renderError() ?>
          <?php echo $form['mascota_id'] ?>
        </td>
      </tr>

      <?php echo $form->renderGlobalErrors() ?>
      <tr class="addEtiquetaFila">
        <td><?php echo $form['servicio_tipo_id']->renderLabel() ?></td>
        <td>
          <?php echo $form['servicio_tipo_id']->renderError() ?>
          <?php echo $form['servicio_tipo_id'] ?>
        </td>
      </tr>
      <tr class="addEtiquetaFila">
        <td><?php echo $form['periodicidad']->renderLabel() ?></td>
        <td>
          <?php echo $form['periodicidad']->renderError() ?>
          <?php echo $form['periodicidad'] ?>
        </td>
      </tr>
      <tr class="addEtiquetaFila">
        <td><?php echo $form['nota']->renderLabel() ?></td>
        <td>
          <?php echo $form['nota']->renderError() ?>
          <?php echo $form['nota'] ?>
        </td>
      </tr>
    
    </tbody>
  </table>


<!--Campo Oculto de evio de variable de ID del usuario-->
<input type="hidden" name="idUser" value='<?php echo $idUser ?>'/>
<input type="hidden" name="parent" value='<?php echo $parent ?>'/>

<!--Lista de Acciones del Formulario-->
<div class="jwj-callcenter-div"></div>
<div id="jwj-callcenter-action">
           <?php echo $form->renderHiddenFields(false) ?>
          <?php if (!$form->getObject()->isNew()): ?>
           <?php //echo link_to('Delete', 'formulario/deleteDireccion?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <button type="button" id="jwj-callcenter-form-delete" class="jwj-callcenter-form-red" title="Listar" onclick="javascript:LoadUserDelete('<?php echo url_for('formulario/deleteServicio'); ?>',<?php echo $idUser; ?>,'<?php echo "id=".$form->getObject()->getId(); ?>','#slideDer-intConten');" >Eliminar</button>
          <?php endif; ?>
          <input type="submit" value="Save" id="jwj-callcenter-form-save" class="jwj-callcenter-form-red"/>
          <button type="button" id="AddBoton-Listar" class="jwj-callcenter-form-red" title="Listar" onclick="javascritp:LoadUser('<?php echo url_for('formulario/indexServicio');?>','<?php echo $idUser ?>','#slideDer-intConten');" >Listar</button>
          <button type="button" id="AddBoton-Cerrar" title="Cerrar" class="AddBotonTools" onclick="javascritp:LoadUser('<?php echo url_for('dashboard/'.$parent)?>','<?php echo $idUser ?>','');MenuClose();">Cerrar</button>
</div>

</form>

<!--Ejecucion del Formulario por Jquery para evitar recarga-->
<script type="text/javascript">

// prepare tde form when tde DOM is ready
$(document).ready(function() {
    var options = {
        target:        '#slideDer-intConten',   // target element(s) to be updated witd server response
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse  // post-submit callback

        // otder available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        //resetForm: true        // reset tde form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000
    };

    // bind form using 'ajaxForm'
    $('#myForm').ajaxForm(options);
});

// pre-submit callback
function showRequest(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but tde form plugin does tdis for you automatically when it submits tde data
    var queryString = $.param(formData);

    // jqForm is a jQuery object encapsulating tde form element.  To access tde
    // DOM element for tde form do tdis:
    // var formElement = jqForm[0];

    //alert('About to submit: \n\n' + queryString);

    // here we could return false to prevent tde form from being submitted;
    // returning anytding otder tdan false will allow tde form submit to continue
    return true;
}

// post-submit callback
function showResponse(responseText, statusText, xhr, $form)  {

        LoadUser('<?php echo url_for("dashboard/$parent"); ?>','<?php echo $idUser; ?>','');
        
}
</script>

